Set gas limit according to TxPermission.blockGasLimit.#140
Conversation
|
Can we first try to do the same without calling the |
|
Right, that would make things easier; basically we could just implement a configurable gas limit schedule, so one could write something like this into the chain spec: "gasLimitSchedule": {
"period": "200",
"defaultLimit": "8000000",
"schedule": [
{ "from": "161", "to": "200", "limit": "2000000" },
{ "from": "0", "to": "239", "limit": "2000000" }
]
} |
|
The formula for those bands is: limit the block gas when the current block number is greater than stakingEpochEndBlock() - MAX_VALIDATORS * DELEGATORS_ALIQUOT - 1 or is less than stakingEpochStartBlock() + MAX_VALIDATORS * DELEGATORS_ALIQUOT + 1 It would be equivalent of calling the So, these values can be read once per staking epoch and used statically in Parity code. What do you think about it? |
|
Or that, yes. |
|
We could make in Parity a function like that: fn limit_block_gas(block_number: U256) -> bool {
if staking_epoch_duration <= 0 || max_validators <= 0 || delegators_aliquot <= 0 {
return false;
}
let staking_epoch = block_number / staking_epoch_duration;
let from = staking_epoch_duration * staking_epoch + max_validators * delegators_aliquot + 1;
let to = staking_epoch_duration * (staking_epoch + 1) - max_validators * delegators_aliquot - 1;
if block_number <= from || block_number >= to {
true
} else {
false
}
}where
I think we should read these constant values from the contracts anyway because in case of writing their values to This approach assumes that those constants and the formula will never be changed during the network's life. |
|
But then we might as well just call Still, I think the cleanest approach would be if we'd manage to call the function really at the right block. I'll try to dig through the code some more and see if we can do that. |
|
We also need to make a decision regarding the gas limit values if the function returns We could change |
|
Ok, let's change the function so that it would return gas limit instead of boolean value. Let's do this after you ensure that we can call the function at the right block (as you wrote above). |
|
In We could:
We should also decide what to do in terms of backward compatibility:
|
|
Let's postpone this task a while, I'll try to repeat stress tests again and recheck those 80 blocks when switching staking epoch to see more closely how it is critical to have reduced gas limit. |
|
I implemented the third option: |
|
As discussed, I will add a separate |
WIP: This passes the
posdao-test-setup, but both the low and the regular gas limits are still hard-coded, and the call inverify_header_paramsuses the wrong header at the moment. (See TODOs.)It also extends the
Enginetrait in a way that's not exactly sane. And it doesn't allow for a variable gas limit.And crucially, I don't know yet whether the state of the block hash that we use for the
limitBlockGascall is always available in the client's database, especially if there's a fork; or whether and how this will work together with snapshots and warp sync.Closes #119.